<?php
if (!class_exists('BaseDao')) {
	/**
	 *  Manager class for database operations
	 *	@author Alecsandru Gabriel DINU
	 *  @since Jun 18, 2008
	 */
	class BaseDao {
		protected $config = null; 
		
		/**
		 * Class constructor
		 * @access public
		 */
		public function __construct() {
			$this->config = AlfaConfiguration::getInstance();
		}		
		
		/**
		 * Dao init method
		 * @access public
		 */
		public function init() {
		}		
		
		/**
		 * Returns propel template if the selected orm
		 * is Propel
		 * @access public
		 * @return PropelTemplate
		 */
		public function getPropelTemplate() {
			$orm = $this->config->getString("database/orm", "propel");
			if ($orm != "propel") {
				throw new ConfigurationException("This method is available only for Propel orm.");				
			}			
			return PropelTemplate::getInstance();
		}
		
		/**
		 * Returns doctrine template if the selected orm
		 * is Doctrine
		 * @access public
		 * @return DoctrineTemplate
		 */
		public function getDoctrineTemplate() {
			$orm = $this->config->getString("database/orm", "propel");
			if ($orm != "doctrine") {
				throw new ConfigurationException("This method is available only for Doctrine orm.");				
			}			
			return new DoctrineTemplate();
		}

		/**
		 * Returns ezpdo template if the selected orm
		 * is EZPDO
		 * @access public
		 * @return EzpdoTemplate
		 */
		public function getEzpdoTemplate() {
			$orm = $this->config->getString("database/orm", "propel");
			if ($orm != "ezpdo") {
				throw new ConfigurationException("This method is available only for Ezpdo orm.");				
			}			
			return new EzpdoTemplate();
		}		
		
	}
}
?>